Skip to content

fix: make concat! work with char #12942

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 8, 2022
Merged

Conversation

lowr
Copy link
Contributor

@lowr lowr commented Aug 4, 2022

Fixes #12921

@Veykril
Copy link
Member

Veykril commented Aug 5, 2022

but we're not actually responsible for serializing it but rowan is.

That is wrong, rowan is not a rust-specific library and that behavior is tied to rust. So if \0 has to be turned into \u{0} for correctness purposes we have to do that here as well. Though I am not sure if this escape_default-ing is actually observable by rust code

@lowr
Copy link
Contributor Author

lowr commented Aug 5, 2022

Ah ok, thanks for the correction!

As for the correctness, there are several characters that we need to escape, see rust-lang/rust#50391 (comment), but we're already escaping them when we convert strings to TokenTrees here with str::escape_debug(), so we should already be correct. I've pushed a commit that replaces escape_debug() with escape_default() and that should output string literals expanded from macro in the same manner as rustc. How does this look now?

@Veykril
Copy link
Member

Veykril commented Aug 8, 2022

Thanks!
@bors r+

@bors
Copy link
Contributor

bors commented Aug 8, 2022

📌 Commit 4d5873e has been approved by Veykril

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Aug 8, 2022

⌛ Testing commit 4d5873e with merge b569bbb...

@bors
Copy link
Contributor

bors commented Aug 8, 2022

☀️ Test successful - checks-actions
Approved by: Veykril
Pushing b569bbb to master...

@bors bors merged commit b569bbb into rust-lang:master Aug 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Macro expansion: concat!() macro with single quotes escapes special characters while rustc does not
3 participants